<?php
class poll_tag {
	private $poll,$pollinfo;
	public function __construct() {
		$this->poll = pc_base::load_model('polls_model');
		$this->pollinfo = pc_base::load_model('polls_info_model');
	}
	
	/**
	 * 轮询标签
	 * {pc:poll action="polllist" pollid="1" siteid="1"}
     * {loop $data $r}
     * <li>{$r[title]}{$r[titlepic]}{$r[titleurl]}</li>
     * {/loop}
     * {/pc}
     * siteid 站点
     * action 方法名
     * pollid 轮询id
	 * @param $data
	 */
	public function polllist($data) {
		$pollid = intval($data['pollid']);
		$siteid = $data['siteid']?intval($data['siteid']):1;
		$poll = file_get_contents(API_URL."/xinsilu/v1/polls/pollsInfo?pollsId=".$pollid."&siteid=".$siteid);
		$poll= json_decode($poll,true);
		$pollInfo = $poll['data'];
		return $pollInfo;
	}


	public function pollname($data) {
		$varname = trim($data['varname']);
		$poll = $this->poll->get_one(array('varname'=>$varname));
		return $poll['description'];
	}

}